package com.googlecode.gwtbb.client.shared.entity.picture;

import com.googlecode.gwtbb.client.shared.entity.Snappable;
import com.googlecode.gwtbb.client.shared.entity.properties.HasId;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author Abraham Grief
 * @version $Id$
 * @since Jul 31, 2008
 */
public class Picture extends PictureBase implements Snappable {
	private Thumb primaryThumb;
	private Info info;

	public Picture() {
	}

	public Picture(Long pictureId, String url, int bytes, int width, int height, String caption, Date snapDate) {
		super(pictureId, url, bytes, width, height, caption, snapDate);
	}

	public Info getInfo() {
		return info;
	}

	public void setInfo(Info info) {
		this.info = info;
	}

	public Thumb getPrimaryThumb() {
		return primaryThumb;
	}

	public void setPrimaryThumb(Thumb primaryThumb) {
		this.primaryThumb = primaryThumb;
	}

	public Long getId() {
		return pictureId;
	}

	public void setId(Long id) {
		pictureId = id;
	}

	/**
	 * Additional info that may be returned with the picture when pulling from the db.
	 */
	public static class Info implements HasId, Serializable {
		private Long pictureId;
		private List<Thumb> thumbs;

		public Long getPictureId() {
			return pictureId;
		}

		public void setPictureId(Long pictureId) {
			this.pictureId = pictureId;
		}

		public List<Thumb> getThumbs() {
			return thumbs;
		}

		public void setThumbs(List<Thumb> thumbs) {
			this.thumbs = thumbs;
		}

		public Long getId() {
			return pictureId;
		}

		public Thumb getLargeThumb() {
			return thumbs != null && !thumbs.isEmpty() ? thumbs.get(thumbs.size() - 1) : null;
		}

		public Thumb getSmallThumb() {
			return thumbs != null && !thumbs.isEmpty() ? thumbs.get(0) : null;
		}

		public void setId(Long id) {
			this.pictureId = id;
		}
	}
}
